package	com.yunfeng.aolin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yunfeng.aolin.entity.SendMaterials;
import com.yunfeng.aolin.dao.SendMaterialsDAO;
import com.yunfeng.aolin.service.SendMaterialsService;
import com.yunfeng.common.util.Page;
import com.yunfeng.common.util.PageUtils;

@Service
@Transactional
public class SendMaterialsServiceImpl implements SendMaterialsService {
	
	@Autowired
	private SendMaterialsDAO sendMaterialsDAO;

	/**   
	 * @param id
	 * @return  
	 * @see com.yunfeng.aolin.service.SendMaterialsService#get(java.lang.Long)  
	 */ 
	@Override
	public SendMaterials get(Long id) {
		return sendMaterialsDAO.findOne(id);
	}

	/**   
	 * @param sendMaterials  
	 * @see com.yunfeng.aolin.service.SendMaterialsService#saveOrUpdate(com.yunfeng.aolin.entity.SendMaterials)  
	 */
	@Override
	public void saveOrUpdate(SendMaterials sendMaterials) {
		sendMaterialsDAO.save(sendMaterials);
	}

	/**   
	 * @param id  
	 * @see com.yunfeng.aolin.service.SendMaterialsService#delete(java.lang.Long)  
	 */
	@Override
	public void delete(Long id) {
		sendMaterialsDAO.delete(id);
	}

	@Override
	public List<SendMaterials> findAll() {
		// TODO Auto-generated method stub
		return sendMaterialsDAO.findAll();
	}

	/**   
	 * @param page
	 * @return  
	 * @see com.yunfeng.aolin.service.SendMaterialsService#findAll(com.ketayao.ketacustom.util.dwz.Page)  
	 */
	@Override
	public List<SendMaterials> findAll(Page page) {
		org.springframework.data.domain.Page<SendMaterials> springDataPage = sendMaterialsDAO.findAll(PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
	
	/**   
	 * @param page
	 * @param liaohao
	 * @return  
	 * @see com.yunfeng.aolin.service.SendMaterialsService#findByLiaohao(com.ketayao.ketacustom.util.dwz.Page, java.lang.String)  
	 */
	@Override
	public List<SendMaterials> findByLiaohao(Page page, String liaohao) {
		org.springframework.data.domain.Page<SendMaterials> springDataPage = sendMaterialsDAO.findByLiaohaoContaining(liaohao, PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
	
	/**
	 * 
	 * @param specification
	 * @param page
	 * @return
	 * @see com.yunfeng.aolin.service.SendMaterialsService#findByExample(org.springframework.data.jpa.domain.Specification, com.ketayao.ketacustom.util.dwz.Page)	
	 */
	@Override
	public List<SendMaterials> findByExample(
			Specification<SendMaterials> specification, Page page) {
		org.springframework.data.domain.Page<SendMaterials> springDataPage = sendMaterialsDAO.findAll(specification, PageUtils.createPageable(page));
		page.setTotalCount(springDataPage.getTotalElements());
		return springDataPage.getContent();
	}
}
